<?php
    echo Util::htmlBotaoNovo(Loja::NOME_MODULO);
    echo Util::htmlBotaoSair();
?>
   <br/><br/>
   <h1>Listagem de Lojas</h1><br/><br/>
<table cellpadding="0" cellspacing="0" border="0" id="table" class="sortable">
    <thead>
            <tr>
                    <th class="nosort"><h4>Código</h4></th>
                    <td><h4>Nome</h4></td>
                    <td><h4>Cidade</h4></td>
                    <td><h4>Operações</h4></td>
            </tr>
    </thead>
    <tbody>
        <?php
            $listaLojas = Loja::listar();
           // $countLinha = 0;
            foreach ($listaLojas as $loja) {
             $cid = Cidade::consultarPorID($loja->getCidade());

        ?>                
            <tr>
                <td class="campoLista"><?=$loja->getIdLoja()?></td>
                <td class="campoLista"><?=$loja->getNome()?></td>
                <td class="campoLista"><?= utf8_encode($cid->getNome()) ?></td>
                <td class="campoLista"><?=Util::htmlOperacoesListagem(Loja::NOME_MODULO, $loja->getIdLoja())?></td>
            </tr>
        <?php } ?>
   </tbody>
</table>   
<div id="controls">
		<div id="perpage">
			<select onchange="sorter.size(this.value)">
			<option value="5" selected="selected">5</option>
				<option value="10">10</option>
				<option value="20">20</option>
			</select>
			<span>Por Página</span>
		</div>
		<div id="navigation">
			<img src="images/first.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1,true)" />
			<img src="images/previous.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1)" />
			<img src="images/next.gif" width="16" height="16" alt="First Page" onclick="sorter.move(1)" />
			<img src="images/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
		</div>
		<div id="text">Página <span id="currentpage"></span> De <span id="pagelimit"></span></div>
	</div>
	
	<script type="text/javascript">
  var sorter = new TINY.table.sorter("sorter");
	sorter.head = "head";
	sorter.asc = "asc";
	sorter.desc = "desc";
	sorter.even = "evenrow";
	sorter.odd = "oddrow";
	sorter.evensel = "evenselected";
	sorter.oddsel = "oddselected";
	sorter.paginate = true;
	sorter.currentid = "currentpage";
	sorter.limitid = "pagelimit";
	sorter.init("table",1);
  </script>